package com.itheima.d2_threadmethod;
/**
 * join 方法：让调用当前这个方法的线程先执行完
 */
public class ThreadMethodDemo3 {
    public static void main(String[] args) throws InterruptedException {
        MyThread3 t1 = new MyThread3();
        t1.setName("线程1");
        t1.start();


        for (int i = 0; i < 10; i++) {
            System.out.println("主线程正在执行..."+  i);
            if(i==1){
                t1.join();
            }
        }
    }
}class MyThread3 extends Thread{
    public void run() {
        for (int i = 1; i <= 10; i++) {
            Thread t = Thread.currentThread();
            System.out.println("线程" +t.getName()+":"+ i);
        }
    }
}
